package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HmzMoneyInfo;
import com.ruoyi.system.service.IHmzMoneyInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 金额记录Controller
 *
 * @author ruoyi
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/system/HmzMoneyInfo")
public class HmzMoneyInfoController extends BaseController
{
    @Autowired
    private IHmzMoneyInfoService hmzMoneyInfoService;

    /**
     * 查询金额记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:HmzMoneyInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(HmzMoneyInfo hmzMoneyInfo)
    {
        startPage();
        List<HmzMoneyInfo> list = hmzMoneyInfoService.selectHmzMoneyInfoList(hmzMoneyInfo);
        return getDataTable(list);
    }

    @RequestMapping("/listMonety")
    public AjaxResult listMonety()
    {
        JSONObject jsonObject = hmzMoneyInfoService.listMonety();
        return  success(jsonObject);
    }

    /**
     * 导出金额记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:HmzMoneyInfo:export')")
    @Log(title = "金额记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HmzMoneyInfo hmzMoneyInfo)
    {
        List<HmzMoneyInfo> list = hmzMoneyInfoService.selectHmzMoneyInfoList(hmzMoneyInfo);
        ExcelUtil<HmzMoneyInfo> util = new ExcelUtil<HmzMoneyInfo>(HmzMoneyInfo.class);
        util.exportExcel(response, list, "金额记录数据");
    }

    /**
     * 获取金额记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:HmzMoneyInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hmzMoneyInfoService.selectHmzMoneyInfoById(id));
    }

    /**
     * 新增金额记录
     */
    @PreAuthorize("@ss.hasPermi('system:HmzMoneyInfo:add')")
    @Log(title = "金额记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HmzMoneyInfo hmzMoneyInfo)
    {
        return toAjax(hmzMoneyInfoService.insertHmzMoneyInfo(hmzMoneyInfo));
    }

    /**
     * 修改金额记录
     */
    @PreAuthorize("@ss.hasPermi('system:HmzMoneyInfo:edit')")
    @Log(title = "金额记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HmzMoneyInfo hmzMoneyInfo)
    {
        return toAjax(hmzMoneyInfoService.updateHmzMoneyInfo(hmzMoneyInfo));
    }

    /**
     * 删除金额记录
     */
    @PreAuthorize("@ss.hasPermi('system:HmzMoneyInfo:remove')")
    @Log(title = "金额记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hmzMoneyInfoService.deleteHmzMoneyInfoByIds(ids));
    }
}
